import { getAction } from '@/api/manage'

// 各个单据的数据详情页面和审核接口
export const billInfo = {
  '1': {
    billName: '采购订单',
    name: 'purchaseManage-purchaseBill-billPurchaseOrder',
    url: '/xghPurchaseOrder/xghPurchaseOrder/changeStatus',
    code: '5'
  },
  '2': {
    billName: '采购入库单',
    name: 'purchaseManage-purchaseBill-billPurchaseWarehousing',
    url: '/xghBuyOrder/xghBuyOrder/changeStatus',
    code: '5'
  },
  '3': {
    billName: '采购退货单',
    name: 'purchaseManage-purchaseBill-billPurchaseReturn',
    url: '/xghBuyOrder/xghBuyOrder/changeStatus',
    code: '5'
  },
  '4': {
    billName: '采购换货单',
    name: 'purchaseManage-purchaseBill-billPurchaseExchange',
    url: '/xghBuyOrder/xghBuyOrder/changeStatus',
    code: '5'
  },
  '5': {
    billName: '销售订单',
    name: 'saleManage-salesBill-billSalesOrder',
    url: '/xghSaleOrder/xghSaleOrder/changeStatus',
    code: '5'
  },
  '6': {
    billName: '销售出库单',
    name: 'saleManage-salesBill-billSalesDelivery',
    url: '/xghSaleStorehouseOrder/xghSaleStorehouseOrder/changeStatus',
    code: '5'
  },
  '7': {
    billName: '销售退货单',
    name: 'saleManage-salesBill-billSalesReturn',
    url: '/xghSaleStorehouseOrder/xghSaleStorehouseOrder/changeStatus',
    code: '5'
  },
  '8': {
    billName: '销售换货单',
    name: 'saleManage-salesBill-billSalesExchange',
    url: '/xghSaleStorehouseOrder/xghSaleStorehouseOrder/changeStatus',
    code: '5'
  },
  '9': {
    billName: '盘点单',
    name: 'stockManage-stockBill-billInventoryOrder',
    url: ''
  },
  '10': {
    billName: '报损单',
    name: 'stockManage-stockBill-billFrmLossOrder',
    url: '/xghProfitLossOrder/xghProfitLossOrder/audit'
  },
  '11': {
    billName: '报溢单',
    name: 'stockManage-stockBill-billOverflowOrder',
    url: '/xghProfitLossOrder/xghProfitLossOrder/audit'
  },
  '12': {
    billName: '调拨单',
    name: 'stockManage-stockBill-billtTransferOrder',
    url: '/xghAllotOrder/xghAllotOrder/audit'
  },
  '13': {
    billName: '成本调整单',
    name: 'stockManage-stockBill-billCostAdjustment',
    url: '/xghAdjustOrder/xghAdjustOrder/audit'
  },
  '14': {
    billName: '收款结算单',
    name: 'paymentManage-paymentBill-billCollectionSettlement',
    url: 'xghSettlementOrder/xghSettlementOrder/verify'
  },
  '15': {
    billName: '付款结算单',
    name: 'paymentManage-paymentBill-billPaymentSettlement',
    url: 'xghSettlementOrder/xghSettlementOrder/verify'
  },
  '16': {
    billName: '期初入库单',
    name: 'stockManage-stockBill-billCostAdjustment',
    url: ''
  },
  '17': {
    billName: '期初应收应付单',
    name: 'stockManage-stockBill-billCostAdjustment',
    url: ''
  },
  // '18': {
  //   billName: '库存调整单',
  //   name: 'adjustmentMemo-adjustmentBill-billInventoryAdjustment',
  //   url: '/xghAdjustStock/xghAdjustStock/audit'
  // },
  '19': {
    billName: '资金增加',
    name: 'adjustmentMemo-adjustmentBill-billIncreaseInFunds',
    url: '/xghAccountMoneyChange/xghAccountMoneyChange/audit'
  },
  '20': {
    billName: '资金减少',
    name: 'adjustmentMemo-adjustmentBill-billDecreaseInFunds',
    url: '/xghAccountMoneyChange/xghAccountMoneyChange/audit'
  },
  '21': {
    billName: '应收款增加',
    name: 'adjustmentMemo-adjustmentBill-billIncreaseInReceivables',
    url: '/xghShouldCollectionPayChange/xghShouldCollectionPayChange/audit'
  },
  '22': {
    billName: '应收款减少',
    name: 'adjustmentMemo-adjustmentBill-billDecreaseInReceivables',
    url: '/xghShouldCollectionPayChange/xghShouldCollectionPayChange/audit'
  },
  '23': {
    billName: '应付款增加',
    name: 'adjustmentMemo-adjustmentBill-billIncreaseInPayable',
    url: '/xghShouldCollectionPayChange/xghShouldCollectionPayChange/audit'
  },
  '24': {
    billName: '应付款减少',
    name: 'adjustmentMemo-adjustmentBill-billDecreaseInPayable',
    url: '/xghShouldCollectionPayChange/xghShouldCollectionPayChange/audit'
  },
  '25': {
    billName: '其他入库单',
    name: 'otherBill-otherWarehousing',
    url: '/xghBuyOrder/xghBuyOrder/changeStatus',
    code: '5'
  },
  '26': {
    billName: '其他出库单',
    name: 'other-otherDelivary',
    url: '/xghBuyOrder/xghBuyOrder/changeStatus',
    code: '5'
  },
  '27': {
    billName: '一般费用单',
    name: 'paymentManage-paymentBill-billGeneralSettlement',
    url: '/costOrder/xghGeneralCostOrder/changeStatus',
  },
  '28': {
    billName: '其他收入单',
    name: 'paymentManage-paymentBill-billOtherSettlement',
    url: '/costOrder/xghGeneralCostOrder/changeStatus',
  },
  '29': {
    billName: '物流代收结算单',
    name: 'paymentManage-paymentBill-logisticsCollection',
    url: '/xghSettlementOrder/xghSettlementOrder/verify',
  },
  '30': {
    billName: '物流代付结算单',
    name: 'paymentManage-paymentBill-logisticsPaymentAgency',
    url: '/xghSettlementOrder/xghSettlementOrder/verify',
  },
  '31': {
    billName: '物流运费结算单',
    name: 'paymentManage-paymentBill-logisticsFreightSettlement',
    url: '/xghSettlementOrder/xghSettlementOrder/verify',
  },
  '35': {
    billName: '转账单',
    name: 'paymentManage-paymentBill-billTransferSettlement',
    url: '/transfer/xghTransferOrder/changeStatus',
  },
}

/**
 * 跳转到对应单据页面
 * @param {*} that  传递this
 * @param {*} billType 单据类型
 * @param {*} billId 单据id
 */
export function toBillDetail(that, billType, billId) {
  const data = billInfo[billType]
  if (!data) {
    return that.$elMessage.warning('不支持的单据类型')
  }
  if (billId && billId.length > 0) {
    that.$router.push({
      name: data.name,
      params: {
        billId,
      },
    })
  } else {
    that.$router.push({
      name: data.name,
    })
  }
}

/**
 * 审核对应单据
 * @param {*} billType 单据类型
 * @param {*} billId 单据id
 */
export function toBillAudit(billType, billId) {
  const val = billInfo[billType]
  let data = { id: billId }
  if (val.code) {
    data.code = val.code
  }
  return getAction(val.url, data)
}
